using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

/// <summary>
/// Summary description for RAnswer
/// </summary>

    public class RAnswer
    {
        private List<Answer> list;

        public RAnswer(Participant pariticipant, IDbConnection connection)
        {

            string sql_script1 = @"SELECT * FROM Questions ORDER BY [Questions].no ";

            string sql_script2 = @"SELECT * FROM Answers where participant_id = "
                            + pariticipant.ParticipantID; 

            IDbCommand cmd = connection.CreateCommand();
            cmd.CommandText = sql_script1;
            IDataReader dr = cmd.ExecuteReader();
            list = new List<Answer>();

            while (dr.Read())
            {
                Answer ans = new Answer();
                ans.Number = Convert.ToInt32(dr["no"].ToString());
                //ans.QuestionDescription = dr["description"].ToString();
                list.Add(ans);
            }
            dr.Close();            
        }

        public IEnumerable<Answer> LoadAnswers()
        {
            return list;
        }
    }
